<?php

class Ext_Account_Adapter
{
    public $username;
    public $email;

    public function __construct($userId)
    {
        $front = Zend_Controller_Front::getInstance();
        $bootstrap = $front->getParam('bootstrap');
        $options = $bootstrap->getApplication()->getOptions();

        $classname = "Ext_Account_Adapter_".ucfirst($options['auth']['adapter']['base']);
        if(!class_exists( $classname ))
        {
            require_once 'Ext/Account/Exception.php';
            throw new Ext_Account_Exception("Account adapter '".$classname."' is not exists.");
        }

        $adapter = new $classname($userId);
        
        $this->username = $adapter->username;
        $this->email    = $adapter->email;
    }
}
